package org.store.domain;

public class Buyer extends Identified {
    private final String name;
    private final String email;
    private final Address shipmentAddress;

    public Buyer(String name, String email, Address shippmentAddress) {
        this.name = name;
        this.email = email;
        this.shipmentAddress = shippmentAddress;
    }

    public String getName() {
        return name;
    }

    public String getEmail() {
        return email;
    }

    public Address getShipmentAddress() {
        return shipmentAddress;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (!(o instanceof Buyer)) return false;
        if (!super.equals(o)) return false;

        Buyer buyer = (Buyer) o;

        if (email != null ? !email.equals(buyer.email) : buyer.email != null) return false;
        if (name != null ? !name.equals(buyer.name) : buyer.name != null) return false;
        if (shipmentAddress != null ? !shipmentAddress.equals(buyer.shipmentAddress) : buyer.shipmentAddress != null)
            return false;

        return true;
    }

    @Override
    public int hashCode() {
        int result = super.hashCode();
        result = 31 * result + (name != null ? name.hashCode() : 0);
        result = 31 * result + (email != null ? email.hashCode() : 0);
        result = 31 * result + (shipmentAddress != null ? shipmentAddress.hashCode() : 0);
        return result;
    }
}
